home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / rexx / 118 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: news.ox.ac.uk!news
  2. From: imc@ecs.ox.ac.uk (Ian Collier)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Object Rexx (was Re: How can I pass an array (stem) to a function?
  5. Date: 8 Jan 1996 18:06:05 GMT
  6. Organization: Oxford University Computing Laboratory
  7. Distribution: inet
  8. Message-ID: <7601.imc@comlab.ox.ac.uk>
  9. References: <7579.imc@comlab.ox.ac.uk> <4b6jdt$nmp@osiris.wu-wien.ac.at>
  10. NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
  11. X-Local-Date: Monday, 8th January 1996 at 6:06pm GMT
  12.  
  13. In article <4b6jdt$nmp@osiris.wu-wien.ac.at>, Rony.Flatscher@wu-wien.ac.at
  14. wrote:
  15. >>>>Does this mean that a combination such as
  16.  
  17. >>>>   call test 3+4
  18. >>>>   test: use arg x
  19.  
  20. >>>>would not generate an error?  How can you pass an expression by reference?
  21.  
  22. >>>Yes, it would *not* generate an error.
  23.  
  24. >>Can you assign to the variable x, or is x in some way labelled as a constant
  25. >>because it is a reference to the value '7'?
  26.  
  27. >Yup, assignment possible anytime.  "x" is a true variable (as opposed to a
  28. >pseudo variable, which one cannot set).
  29.  
  30. Surely this could lead to accidents.  If for example I put the parameters
  31. in the wrong order then it would carry on as if nothing happened instead
  32. of saying "whoops, there should have been a variable here".
  33.  
  34. In effect, if I type
  35.  
  36.    call test 7
  37.    test: use arg x
  38.    x=6
  39.  
  40. I am asking for the value of '7' to be changed to 6.  As I'm sure most people
  41. know, this actually happened on some versions of FORTRAN.  But REXX will
  42. silently ignore me instead of detecting something wrong.
  43.  
  44. >"USE ARG" essentially allows for defining functions/procedures/routines/methods
  45. >which need to operate directly on the passed in objects themselves (and not on
  46. >their string representation as ARG( n ) or "PARSE ARG").
  47.  
  48. I imagine then that something like
  49.  
  50.    call test .array~new
  51.    test: use arg x
  52.  
  53. is possible.  I can't think of a circumstance in which this would be
  54. useful, but I suppose there must be some uses for passing by reference
  55. something that isn't a variable.  There is no need to do this with
  56. strings though, because they can be passed by value (and since I'm
  57. interested in applications of "use arg" to classic Rexx, strings are
  58. my main consideration).
  59.  
  60. >                        (If a NOVALUE was raised at the "USE ARG" statement this
  61. >(extremely important) technique was impossible to employ, or with other words:
  62. >it would be impossible to write a function/procedure/routine/method such, that
  63. >it could work irrespectivle of supplied arguments !)
  64.  
  65. You would simply have to check before doing the USE ARG instruction.  For
  66. that I would replace the VAR function by ARG(n,'V'), so, to translate your
  67. example...
  68.  
  69.     :: Method Init
  70.        use arg anObject
  71.        if arg(2,"V") then use arg ,bCreate
  72.        else bCreate = .true
  73.        if bCreate then
  74.           self ~ class ~ setup(anObject, self)
  75.  
  76. Ian Collier - imc@comlab.ox.ac.uk - WWW Home Page (including REXX section):
  77. http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html
  78.